package com.qd.common.panda.domain.entity.card.collect;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Optional;

/**
 * 领卷
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class CollectCardDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "领劵ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "领劵ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String cid;
    /**
     * 名称
     */
    @NotBlank(message = "名称不能为空", groups = DefaultGroup.class)
    @Size(max = 100, message = "名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String name;
    /**
     * 备注
     */
    @Size(max = 500, message = "备注长度不能超过{max}位", groups = DefaultGroup.class)
    private String note;
    /**
     * 添加时间
     */
    private LocalDateTime addTime;
    /**
     * 更新时间
     */
    private LocalDateTime updateTime;
    /**
     * 计划ID
     */
    @NotBlank(message = "计划ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "计划ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String planId;
    /**
     * 计划ID显示
     */
    private String planIdDisplay;
    /**
     * 推广码
     */
    @NotBlank(message = "推广码不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "推广码长度不能超过{max}位", groups = DefaultGroup.class)
    private String promotionCode;
    /**
     * 推广码显示
     */
    private String promotionCodeDisplay;
    /**
     * 分享葵花码
     */
    private String qrCode;
    /**
     * 码数量
     */
    private Integer allocatedQuantity;
    /**
     * 码可用数量
     */
    private Integer availableQuantity;
    /**
     * 卷封面
     */
    private CollectCardCoverDTO cover;
    /**
     * 状态
     */
    private Integer state;
    /**
     * 是否无限数量
     */
    private String infiniteQuantity;
    /**
     * 是否回赠
     */
    private String rebate;

    @Override
    public void freeData() {
        this.cid = null;
        this.name = null;
        this.note = null;
        this.addTime = null;
        this.updateTime = null;
        this.planId = null;
        this.planIdDisplay = null;
        this.promotionCode = null;
        this.promotionCodeDisplay = null;
        this.qrCode = null;
        this.allocatedQuantity = null;
        this.availableQuantity = null;
        this.state = null;
        this.infiniteQuantity = null;
        this.rebate = null;
        Optional.ofNullable(cover).ifPresent(CollectCardCoverDTO::freeData);
        super.freeData();
    }
}
